import type {RouteLocationNormalized} from "#vue-router";

export default defineNuxtRouteMiddleware(async (to: RouteLocationNormalized, from: RouteLocationNormalized) => {
    if(import.meta.server)return
    let error: any = null
    await cFetch<StrokePO>('/account/api/verifyToken', {
        auth: true,
        defaultOpts: {
            method: 'POST',
        }
    }).catch(err => {
        error = err
    })
    if (error?.response.status === 401) {
       return navigateTo('/login')
    }
})